/*
 * Copyright 2011-2012 by The Regents of the University of California Licensed
 * under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. you may obtain a copy of the
 * License from
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package edu.ucsd.db.bassarisk.storage.reading;

import java.nio.ByteBuffer;

import edu.ucsd.db.bassarisk.data.api.IValueType;
import edu.ucsd.db.bassarisk.data.api.IValueType.ITypeTools;
import edu.ucsd.db.bassarisk.data.api.IValueType.IValueReference;
import edu.ucsd.db.bassarisk.storage.loading.ColumnSegmentInfo;

public interface IDrawerIndexReader<VT extends IValueType> extends
    IColumnSegmentIndexReader<VT> {

  public class CardInfo<VT extends IValueType> extends ColumnSegmentInfo<VT> {
    private int cardIndex;

    public CardInfo(final ITypeTools<VT> columnTypeTools) {
      super(columnTypeTools);
    }

    public int getCardIndex() {
      return this.cardIndex;
    }

    public void reset(final int cardIndex, final long entryCount,
                      final long firstEntryIndex) {
      this.cardIndex = cardIndex;
      super.reset(entryCount, firstEntryIndex);
    }
  }

  void getCardData(int cardIndex, CardInfo<VT> info);

  boolean getCardDataForEntryIndex(int targetEntryIndex, CardInfo<VT> info);

  boolean getCardDataForValue(IValueReference<VT> value, CardInfo<VT> info);

  int getDataCardCount();

  int getDrawerIndexVersion();

  boolean getNextCardData(CardInfo<VT> info);

  CardInfo<VT> makeCardInfoInstance();

  void resetDrawer(ByteBuffer drawerBuffer, ColumnSegmentInfo<VT> drawerInfo);

}
